<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>文章的编辑</title>
    
    
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-2.0.0.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-ui.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
    
	
  </head>
  
  <body>
    <!-- 配置文件 -->
		<script type="text/javascript" src="${pageContext.request.contextPath }/utf8-jsp/ueditor.config.js" charset="utf-8"></script>
		<!-- 编辑器源码文件 -->
		<script type="text/javascript" src="${pageContext.request.contextPath }/utf8-jsp/ueditor.all.min.js" charset="utf-8"></script>
    <script type="text/javascript">
			function submitData()
			{
				var title = $("#title").val();
				var content = UE.getEditor('editor').getContent();
				var summary = $("#summary").val();
				var id = $("#essayID").val();
				var edate = $("#dateID").val();
				var clickHit = $("#essayhitID").val();
				if(title==null || title=="")
				{
					alert('请输入标题');
				}else if(content==null || content =="")
				{
					alert("请输入内容");
				}
				else if(summary==null || summary =="")
				{
					alert("请输入文章简介");
				}
				else{
					$.post("${pageContext.request.contextPath}/admin/essay_EssayUpdate.action",{
											"essay.ename" : title,
											"essay.content" :content,
											"essay.summary" : summary,
											"essay.date" : edate,
											"essay.id" : id,
											"essay.clickHit" : clickHit
					
					 },function(result){
						if(result)
						{
							alert("文章编辑成功");
							resetValue();
						}
						else
						{
							alert("文章编辑失败");
						}
					},"text");
				
				}
			
			}
			function resetValue()
			{
				$("#title").val("");
				UE.getEditor('editor').setContent("");
				$("#summary").val("");
			}
		</script>
    <div id="p" title="编写文章" style="padding: 10px">
	 	<form action="${pageContext.request.contextPath }/admin/essay_EssayUpdate.action" method="post">
				<s:hidden id="essayID" name="essay.id"/>
				文章标题：<s:textfield id="title" name="essay.ename"/> <br/>
				文章简介：<s:textfield id="summary" name="essay.summary"/> <br/>
				<s:hidden id="essayhitID" name="essay.clickHit"/>
				<s:hidden id="dateID" name="essay.date"/>
				<!-- 加载编辑器的容器 -->
				<!--  <script id="container" name="content" type="text/plain"></script>-->
				文章内容：<s:textarea id="editor" rows="50" cols="50" name="essay.content"></s:textarea>
				<input type="submit" value="提交"/>
			</form>
	 </div>
	 <script type="text/javascript">
		var ue = UE.getEditor('editor');
	</script>
			
  </body>
</html>
